package com.heima;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.WebApplicationContext;

@Configuration
public class WebServerAutoConfiguration implements AutoConfiguration {
    
    private WebApplicationContext applicationContext;
    
    public WebServerAutoConfiguration(WebApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Bean
    @XiejunConditionalOnClass("org.apache.catalina.startup.Tomcat")
    public TomcatWebServer tomcatWebServer(){
        return new TomcatWebServer(applicationContext);
    }

    @Bean
    @XiejunConditionalOnClass("org.eclipse.jetty.server.Server")
    public JettyWebServer jettyWebServer(){
        return new JettyWebServer();
    }
}